﻿/*********************************************************************************
**                                                                              **
**  Copyright (C) 2024 LiLong                                                   **
**  This file is part of RinexFileReader.                                       **
**                                                                              **
**  RinexFileReader is free software: you can redistribute it and/or modify     **
**  it under the terms of the GNU General Public License as published by        **
**  the Free Software Foundation, either version 3 of the License, or           **
**  (at your option) any later version.                                         **
**                                                                              **
**  RinexFileReader is distributed in the hope that it will be useful,          **
**  but WITHOUT ANY WARRANTY; without even the implied warranty of              **
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               **
**  GNU General Public License for more details.                                **
**                                                                              **
**  You should have received a copy of the GNU General Public License           **
**  along with RinexFileReader. If not, see <https://www.gnu.org/licenses/>.    **
**********************************************************************************/
#include "NavigationMessageFile.h"
#include "Private/NavigationMessageData.h"

namespace Rinex
{
struct NavigationMessageFile::Impl
{
    std::shared_ptr<NavigationMessageData> data;
};

NavigationMessageFile::NavigationMessageFile(std::shared_ptr<NavigationMessageData> d) : m_impl(std::make_unique<Impl>(d)) {}

NavigationMessageFile::NavigationMessageFile(NavigationMessageFile&& other) noexcept : m_impl(std::move(other.m_impl)) {}

NavigationMessageFile::NavigationMessageFile(const NavigationMessageFile& other) : m_impl(std::make_unique<Impl>(other.m_impl->data)) {}

NavigationMessageFile::~NavigationMessageFile() {}

double NavigationMessageFile::version() const { return m_impl->data->version; }

SatelliteSystem NavigationMessageFile::satelliteSystem() const { return m_impl->data->system; }

const std::string& NavigationMessageFile::program() const { return m_impl->data->program; }

const std::string& NavigationMessageFile::agency() const { return m_impl->data->agency; }

const std::string& NavigationMessageFile::createDateTime() const { return m_impl->data->createDateTime; }

const std::optional<std::string>& NavigationMessageFile::recNumber() const { return m_impl->data->recNumber; }

const std::optional<std::string>& NavigationMessageFile::recType() const { return m_impl->data->recType; }

const std::optional<std::string>& NavigationMessageFile::recVersion() const { return m_impl->data->recVersion; }

const std::vector<std::string>& NavigationMessageFile::comments() const { return m_impl->data->comments; }

const std::vector<IonosphericCorr>& NavigationMessageFile::ionosphericCorrs() const { return m_impl->data->ionosphericCorrs; }

const std::vector<Rinex::TimeSystemCorr>& NavigationMessageFile::timeSystemCorrs() const { return m_impl->data->timeSystemCorrs; }

const std::optional<int>& NavigationMessageFile::mergedFile() const { return m_impl->data->mergedFile; }

const std::optional<std::string>& NavigationMessageFile::doi() const { return m_impl->data->doi; }

const std::optional<std::string>& NavigationMessageFile::licenseOfUse() const { return m_impl->data->licenseOfUse; }

const std::optional<std::string>& NavigationMessageFile::stationInformation() const { return m_impl->data->stationInformation; }

const LeapSeconds& NavigationMessageFile::leapSeconds() const { return m_impl->data->leapSeconds; }

const std::vector<NMData>& NavigationMessageFile::datas() const { return m_impl->data->datas; }

NavigationMessageFile& NavigationMessageFile::operator=(const NavigationMessageFile& other)
{
    m_impl->data = other.m_impl->data;
    return *this;
}

NavigationMessageFile& NavigationMessageFile::operator=(NavigationMessageFile&& other) noexcept
{
    m_impl = std::move(other.m_impl);
    return *this;
}

} // namespace Rinex